package com.atxiaodei.springsecurity.config;

import org.springframework.security.config.annotation.authentication.builders.AuthenticationManagerBuilder;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configuration.WebSecurityConfigurerAdapter;

/**
 * @ClassName SpringSecurityConfig
 * @Deacription TODO
 * @Author 王盟
 * @Date 2021/3/30 15:53
 * @Version 1.0
 **/
@EnableWebSecurity // aop
public class SpringSecurityConfig extends WebSecurityConfigurerAdapter {


    // 权限
    @Override
    protected void configure(HttpSecurity http) throws Exception {
        // 请求授权的规则
        http.authorizeRequests()
                .antMatchers("/").permitAll()
                .antMatchers("/level1/**").hasRole("");
        // 没有权限默认会跳转到登陆页面，需要开启登陆的页面
        http.formLogin();
    }
    // 认证
    @Override
    protected void configure(AuthenticationManagerBuilder auth) throws Exception {
        super.configure(auth);
    }
}
